import { defineStore } from 'pinia';
import axios from 'axios';

export const useFishProductionStore = defineStore('fishProduction', {
  state: () => ({
    productionData: [],
    loading: false,
    error: null
  }),
  
  actions: {
    async fetchProductionData() {
      this.loading = true;
      try {
        // 实际项目中应该替换为真实API
        // const response = await axios.get('/api/fish-production');
        // this.productionData = response.data;
        
        // 模拟数据
        setTimeout(() => {
          this.productionData = [
            { year: 2018, totalProduction: 6450, marineProduction: 3520, freshwaterProduction: 2930 },
            { year: 2019, totalProduction: 6680, marineProduction: 3610, freshwaterProduction: 3070 },
            { year: 2020, totalProduction: 6520, marineProduction: 3480, freshwaterProduction: 3040 },
            { year: 2021, totalProduction: 6780, marineProduction: 3650, freshwaterProduction: 3130 },
            { year: 2022, totalProduction: 7050, marineProduction: 3820, freshwaterProduction: 3230 },
            { year: 2023, totalProduction: 7320, marineProduction: 3950, freshwaterProduction: 3370 },
          ];
          this.loading = false;
        }, 500);
      } catch (error) {
        this.error = error.message;
        this.loading = false;
      }
    },
    
    async fetchRegionalData() {
      try {
        // 模拟区域数据
        return [
          { region: '东海', production: 1250, percentage: 32 },
          { region: '南海', production: 980, percentage: 25 },
          { region: '黄海', production: 850, percentage: 22 },
          { region: '渤海', production: 520, percentage: 13 },
          { region: '其他海域', production: 310, percentage: 8 },
        ];
      } catch (error) {
        this.error = error.message;
        return [];
      }
    },
    
    async fetchSpeciesProductionData() {
      try {
        // 模拟鱼类产量数据
        return [
          { species: '鲤鱼', production: 850, trend: '+5.2%' },
          { species: '草鱼', production: 780, trend: '+3.8%' },
          { species: '鲫鱼', production: 650, trend: '+2.1%' },
          { species: '带鱼', production: 580, trend: '-1.2%' },
          { species: '黄鱼', production: 520, trend: '+4.5%' },
          { species: '金枪鱼', production: 480, trend: '+6.7%' },
          { species: '鲈鱼', production: 420, trend: '+3.3%' },
          { species: '其他', production: 2720, trend: '+2.8%' },
        ];
      } catch (error) {
        this.error = error.message;
        return [];
      }
    }
  }
}); 